package com.example.shareapp.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

public class ActivityCollector {
	private static List<Activity> activities = new ArrayList<>();
	public static void addAct (Activity activity){
		activities.add(activity);
	}
	public static void removeAct (Activity activity){
		activities.remove(activity);
	}
	public static void finishAct (){
		for(Activity activity : activities){
			if(!activity.isFinishing()){
				activity.finish();
			}
		}
	}

	public static void finishSingAct (Activity activity){
		if (activity == null){
			return;
		}
		if(!activity.isFinishing()){
			activities.remove(activity);
			activity.finish();
		}
	}
}
